package com.example.home.bus.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.home.R;
import com.example.home.bus.bean.BusDetailBean;

import java.util.List;

public class BusRouteAdapter extends RecyclerView.Adapter<BusRouteAdapter.ViewHolder> {

    private List<BusDetailBean.RowsBean> list;
    private Context context;

    public BusRouteAdapter(List<BusDetailBean.RowsBean> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @NonNull
    @Override
    public BusRouteAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.landmark_item,null);
        return new BusRouteAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull BusRouteAdapter.ViewHolder holder, int position) {
        holder.name.setText(list.get(position).getName());
        holder.sequence.setText(String.valueOf(list.get(position).getSequence()));
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView sequence;
        private TextView name;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            sequence = itemView.findViewById(R.id.sequence);
            name = itemView.findViewById(R.id.name);
        }
    }
}


